﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace Twipler.Data.Cache
{
    public class Unfollower : TwitterId
    {
        public DateTime Since;

        public override int ColumnCount
        {
            get { return base.ColumnCount + 1; }
        }

        public override List<TableColumn> Columns
        {
            get
            {
                List<TableColumn> baseList = base.Columns;
                baseList.Add(new TableColumn(false, "Since", "datetime null", "@Since"));
                return baseList;
            }
        }

        public override void FromSqlDataReader(SqlDataReader reader)
        {
            base.FromSqlDataReader(reader);
            Since = (DateTime)reader["Since"];            
        }

    	public override int TableNameParamCount
    	{
			get { return 1; }
    	}

    	public override string TableName
		{
			get { return "_{0}_Unfollowers"; }
		}

    	public override void QueryParams(SqlCommand command, params object[] args)
    	{
            base.QueryParams(command, args);

			if (args.Length >= ColumnCount)
				command.Parameters.Add("@Since", System.Data.SqlDbType.DateTime).Value = (DateTime)args[ColumnCount - 1];
    	}
    }
}
